<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>图书列表</title>
    <link rel="stylesheet" type="text/css" th:href="@{/dist/css/bootstrap.min.css}">
    <link rel="stylesheet" type="text/css" th:href="@{/css/index.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/animate.css}"/>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">

</head>
<body>
<!--导航部分  begin-->
<div th:replace="common/header :: nav"></div>
<!--导航部分 end-->

<!--最顶端轮播图片 begin-->
<div th:replace="common/carousel :: carousel"></div>
<!--最顶端轮播图片 end-->

<div class="container">
    <ol class="breadcrumb">
        <li >搜索结果：<span th:text="${bookList.size()}"></span>本</li>

    </ol>
</div>

<!--展示数据开始-->
<div class="container">
    <div class="row">
        <div class="col-sm-6 col-md-3" th:each="book:${bookList}">
            <div class="thumbnail">
                <a href="details.html" th:href="@{/book/detail(id=${book.id})}"><img th:src="@{'/public/'+ ${book.imgUrl}}" alt="通用的占位符缩略图"></a>
                <div class="caption">
                    <h3 th:classappend="h3-height" th:text="${book.name}">北纬78°</h3>
                    <p th:classappend="p-height">价格:<span th:text="'￥'+${book.newPrice}" style="color:#FA5000">19.5元</span>&nbsp;&nbsp;作者:<span th:text="${book.author}">陈丹燕</span>&nbsp;&nbsp;</p>
                    <p>
                        <a href="details.html" th:href="@{/book/detail(id=${book.id})}">
                            更多信息
                        </a>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>
<!--展示数据结束-->

<!--地址-->
<!--首页底部信息 begin-->
<div th:replace="common/footer :: footer"></div>
<!-- 登录模态框（Modal） -->
<!-- 注册modal end/.modal -->
<div th:replace="common/bookModal :: bookModal"></div>
<!--end-->
<script src="dist/js/jquery.min.js" th:src="@{/dist/js/jquery.min.js}"></script>
<script src="js/carousel.js" th:src="@{/js/carousel.js}" type="text/javascript" charset="utf-8"></script>
<script src="dist/js/bootstrap.min.js" th:src="@{/dist/js/bootstrap.min.js}"></script>
<script src="js/wow.js" th:src="@{/js/wow.js}"></script>
<script th:src="@{/js/login_reg.js}"></script>
<script th:src="@{/layui/layui.js}"></script>

<script th:inline="javascript">
    //获取应用路径
    var contextPath = [[${#request.getContextPath()}]];
    var category = [[${category}]];
</script>
<script type="text/javascript">
    if (!(/msie [6|7|8|9]/i.test(navigator.userAgent))) {
        new WOW().init();
    };
    //首次进入图书类型
    $(function () {
        $("#bookList").load(contextPath + "/book/getBookListData", queryData(1,'', category))
    });

    function queryData(page, pageSize, category) {
        var query = {};
        query.category = category;
        query.page = page;
        query.pageSize = (pageSize == '' ? 4 : pageSize);
        return query;
    };

    function loadData(page,pageSize, category) {
        $("#bookList").load(contextPath + "/book/getBookListData", queryData(page,pageSize, category));
    };

    //跳转至指定页
    function goPage(pageSize,category) {
        var page = $("#inputPage").val();
        $("#bookList").load(contextPath + "/book/getBookListData", queryData(page,pageSize, category));
    }

    //每页显示条数
    function loadDataBySize(obj) {
        var pageSize = obj.value;
        //回到第一页
		$("#bookList").load(contextPath + "/book/getBookListData", queryData(1,pageSize, category));
    }
    //根据图书名搜索
    function searchBookName() {
        var inputBookName = $("#inputBookName").val();
        if (inputBookName != ''){
            window.location.href = contextPath + "/book/searchBook?inputBookName=" + inputBookName;
        }else alert('查找内容不为空')
    }
</script>
</body>
</html>
